@isTest

Private class WorkflowEditControllerTest{


    static testMethod void test_WorkflowTest()

    {
            Workflow_Definition__c WDF = new Workflow_Definition__c();
            WDF.Status__c = 'Active';
            WDF.Workflow_Name__c = 'WD';
            insert WDF;

            PageReference pageRef = Page.WorkflowEditPage;
            Test.setCurrentPage(pageRef);
            ApexPages.StandardController ctrl = new ApexPages.StandardController(WDF);
            WorkflowEditController controller = new WorkflowEditController(ctrl);
        
            Assignment_Group_Name__c AGR = new Assignment_Group_Name__c();
            AGR.name = 'AG1';
            AGR.Function__c = 'Advertiser Approval';
            AGR.Type__c = 'Fulfillment';
            AGR.Description__c = 'Description';
            AGR.Round_Robin__c = true;
            insert AGR;
                        
            Workflow_Activities__c WA = new Workflow_Activities__c();
            WA.name = 'WA1';
            insert WA;
                                              
            Stage_Definition__c StD = new Stage_Definition__c();
            StD.name = 'Advertiser Approval';
            StD.Stage_Description__c = 'Desc';
            StD.Sequence__c = 65;
            StD.Status__c = 'Active';
            insert StD;
            
            Workflow_Stage__c WFS = new Workflow_Stage__c();
            WFS.name = 'WFS';
            WFS.Stage__c = StD.id;
            WFS.Sequence__c = 1;
            WFS.Workflow_Code__c = WDF.id;
            insert WFS;
            
            WF_Assignment_Group__c WAG = new WF_Assignment_Group__c();
            WAG.Workflow_Function__c = WFS.id;
            WAG.AG_Definition__c = AGR.id;
            insert WAG;
            
            Step_definition__c SD = new Step_definition__c();
            SD.name = 'SD1';
            SD.Stage__c = StD.id;
            SD.Step_Sequence__c = 37;
            SD.Target_Days__c = 4;
            SD.Dashboard_Function__c = '';
            SD.status__c='Active';
            insert SD;
            
            Wokflow_Steps__c WST = new Wokflow_Steps__c();
            WST.name = 'WST';
            WST.Wokflow_Stage_Name__c = WFS.id;
            WST.Required__c = true;
            WST.Step__c= SD.id;
            WST.Target_Days__c= 11;
            insert WST;

            //Assignment_Group_Name__c AG = new Assignment_Group_Name__c(name='SG1',Description__c='Desc',);
            
            Activities_Definition__c APD = new Activities_Definition__c();
            APD.name = 'Advertiser Approval';
            APD.Required__c = True;
            APD.Status__c = 'Active';
            APD.Step__c = SD.id;
            insert APD;
            
            controller.selectedStages();
           controller.initilizeAssignmentGroup();
        controller.initilizeTaskAndActivities ();
        controller.saveUpdatedWFDefn();
    
    
    }
}